
Rem
	Returns the decimal equivalent of the hexadecimal number represented
	by the hex_string argument. hexdec() converts a hexadecimal string to a decimal number.

	hexdec() will ignore any non-hexadecimal characters it encounters.
	
	@todo		Simplify the code ( I think it's do-able )
	@author	Nicholas Grant
	@updatedby	
	@return	int
End Rem
Function hexdec:Int( hex_string:String )
	
	Local hstr:String = "";
	Local nord:Int = 0;
	
	hex_string = hex_string.ToUpper();
		
	For Local cnt:Int=0 To hex_string.Length
		nord = Asc(hex_string[cnt..cnt+1]);
		If ( ( nord > 47 And nord < 58 ) Or ..
			(nord > 64 And nord < 71 ) )
			hstr :+ hex_string[cnt..cnt+1];
		End If
	Next
	
	Return Int( base_convert( hstr, 16, 10 ) )
End Function

' Alias function
Function hex2dec:Int( hex_string:String )
	Return hexdec( hex_string );
End Function
